<div class="body-top">

	<div align="left">{$introduction}</div>

{if $loggedIn == true}
	{if $error !== null}
		<div class="error-message"><p>{$error}</p></div>
	{/if}
	{if $warning !== null}
		<div class="warning-message"><p>{$warning}</p></div>
	{/if}
	<form action="{$action}#results" method="post" name="updaut">
		<input name="hidden" type="hidden" value="updaut"></input>
    	<div align="left">TeamID (optional, to check another team):
			<input type="text" maxlength="7" class="team-box" name="teamID" value="{$teamID}"></input>		
		</div>
		<input type="submit" class="updaut" value="Update"></input>
		
	</form>
	<form action="{$action}#results" method="post" name="updman">
		<input name="hidden" type="hidden" value="updman"></input>
		<input type="submit" class="updman_login" value="Update manually"></input>
{else}
	{if $error !== null}
		<div class="error-message"><p>{$error}</p></div>
	{else}
		<div class="info-message"><p>Login with your Hattrick username and security code above and press Update to get your coolness rating automatically!</p></div>
	{/if}
	<form action="{$action}#results" method="post" name="updman">
		<input name="hidden" type="hidden" value="updman"></input>
		<input type="submit" class="updman" value="Update manually"></input>
{/if}		

<table class="coolness">

	<tr>
		<th colspan="5" />
		<th colspan="7"><b>Active users / Tendency</b></th>
		<th colspan="3" />
	</tr>
	<tr>
		<th><b>CD</b></th>
		<th><b>ND</b></th>
		<th><b>English / local country name</b></th>
		<th align="center"><b>Flag</b></th>
		<th><b>Season</b></th>
		<th><b>Active</b><span class="wait"> +w</span></th>
		<th><b>T-1d</b></th>
		<th><b>T-1w</b></th>
		<th><b>T-2w</b></th>
		<th><b>T-3w</b></th>
		<th><b>T-4w</b></th>
		<th><b>T-6w</b></th>
		<th><b>Coolness</b></th>
		<th align="center"><b>A</b></th>
		<th align="center"><b>H</b></th>
	</tr>
	
{foreach from=$coolnessTable item=row name=coolnessTable_loop}
	{assign var=country value=$row->getCountry()}
	<tr bgcolor="{$row->getColor()}">
		<td class="d{$country->getDivisions()}">{$country->getDivisions()}</td>
		<td class="d{$row->getNeededDivisions()}">{$row->getNeededDivisions()}</td>
		<td align="left">{$row->getRank()}. {$country->getEnglishName()} / {$country->getName()}</td>
		<td align="center"><img class="flag" src="./flags/{$country->getCountryID()}_mini.gif" alt="{$country->getName()}" /></td>
		<td align="center">{$country->getSeasons()}</td>
		<td align="center">{$country->getActiveusers()} <span class="wait">+{$country->getWaitingusers()}</span></td>
		{if $row->getWeek1() !== null}
			<td class="graph" bgcolor="{$row->getWeek1_Color()}">
				{if $row->getWeek1() > 0}+{/if}{$row->getWeek1()}<br />
				({if $row->getWeek1() > 0}+{/if}{$row->getWeek1_Percentage()}%)</td>
		{else}
			<td />
		{/if}
		{if $row->getWeek2() !== null}
			<td class="graph" bgcolor="{$row->getWeek2_Color()}">
				{if $row->getWeek2() > 0}+{/if}{$row->getWeek2()}<br />
				({if $row->getWeek2() > 0}+{/if}{$row->getWeek2_Percentage()}%)</td>
		{else}
			<td />
		{/if}
		{if $row->getWeek8() !== null}
			<td class="graph" bgcolor="{$row->getWeek8_Color()}">
				{if $row->getWeek8() > 0}+{/if}{$row->getWeek8()}<br />
				({if $row->getWeek8() > 0}+{/if}{$row->getWeek8_Percentage()}%)</td>
		{else}
			<td />
		{/if}
		{if $row->getWeek16() !== null}
			<td class="graph" bgcolor="{$row->getWeek16_Color()}">
				{if $row->getWeek16() > 0}+{/if}{$row->getWeek16()}<br />
				({if $row->getWeek16() > 0}+{/if}{$row->getWeek16_Percentage()}%)</td>
		{else}
			<td />
		{/if}
		{if $row->getWeek28() !== null}
			<td class="graph" bgcolor="{$row->getWeek28_Color()}">
				{if $row->getWeek28() > 0}+{/if}{$row->getWeek28()}<br />
				({if $row->getWeek28() > 0}+{/if}{$row->getWeek28_Percentage()}%)</td>
		{else}
			<td />
		{/if}
		{if $row->getWeek52() !== null}
			<td class="graph" bgcolor="{$row->getWeek52_Color()}">
				{if $row->getWeek52() > 0}+{/if}{$row->getWeek52()}<br />
				({if $row->getWeek52() > 0}+{/if}{$row->getWeek52_Percentage()}%)</td>
		{else}
			<td />
		{/if}
		<td align="right">{$country->getCoolness()}</td>
		<td><input type="checkbox" name="away[{$country->getCountryID()}]" value="true" {if $row->hasVisited() == true}checked="checked"{/if}></input></td>
		<td><input type="checkbox" name="home[{$country->getCountryID()}]" value="true" {if $row->hasHosted() == true}checked="checked"{/if}></input></td>
	</tr>
{/foreach}

</table>

	<input type="submit" class="updman" value="Update manually"></input>

</form>

{if $results == true}
<a name="results"></a>
<div class="results">
	<div class="box">
		<div class="box-title"><span class="title-16">Coolness rating {$teamname}</span></div>
		<div class="box-inside">
			<div class="results-left">
				<div class="title-14">{$away_title}</div>
				<div align="left">{$away_text}</div>
				<div class="title-14">{$home_title}</div>
				<div align="left">{$home_text}</div>
			</div>
			<div class="results-right">
				<div class="title-14">{$combined_title}</div>
				<div align="left">{$combined_text}</div>
			</div>
			<a name="maps"></a>
			<div class="title-14">{$map_title}</div>
			<div class="maps"><img id="map" src="map/coolmap.php?legend=true" alt="Map"/><br /></div>
			<div align="right"><a href="#maps" onclick="document.getElementById('map').src='map/coolmap.php?legend=true&amp;special=true'">Default with legend</a> |  <a href="#maps" onclick="document.getElementById('map').src='map/coolmap.php?legend=false&amp;special=true'">Default without legend</a> |  <a href="#maps" onclick="document.getElementById('map').src='map/coolmap.php?legend=true&amp;special=false'">Detailed with legend</a> |  <a href="#maps" onclick="document.getElementById('map').src='map/coolmap.php?legend=false&amp;special=false'">Detailed without legend</a></div>
			<div class="results-text">
				<div class="title-14">{$summary_title}</div>
				<table class="coolness">
					<tr>
						<th />
						<th colspan="2"><b>Flags</b></th>
						<th colspan="2"><b>Coolness</b></th>
						<th colspan="2"><b>Countries</b></th>
					</tr>
						<tr>
							<th><b>Type</b></th>
							<th><b>Number</b></th>
							<th><b>Percentage of total *</b></th>
							<th><b>Score</b></th>
							<th><b>Percentage of total **</b></th>
							<th><b>Rarest flag</b></th>
							<th><b>Percentage of score ***</b></th>
						</tr>
						<tr>
							<td>visited</td>
							<td align="right">{$away_flags}</td>
							<td align="right">{$away_flags_percentage} %</td>
							<td align="right">{$away_coolness|number_format:2:".":" "}</td>
							<td align="right">{$away_coolness_percentage} %</td>
							<td>{$away_rarest}</td>
							<td align="right">{$away_rarest_percentage} %</td>
						</tr>
						<tr>
							<td>hosted</td>
							<td align="right">{$home_flags}</td>
							<td align="right">{$home_flags_percentage} %</td>
							<td align="right">{$home_coolness|number_format:2:".":" "}</td>
							<td align="right">{$home_coolness_percentage} %</td>
							<td>{$home_rarest}</td>
							<td align="right">{$home_rarest_percentage} %</td>
						</tr>
						<tr>
							<td>visited AND hosted</td>
							<td align="right">{$and_flags}</td>
							<td align="right">{$and_flags_percentage} %</td>
							<td align="right">{$and_coolness|number_format:2:".":" "}</td>
							<td align="right">{$and_coolness_percentage} %</td>
							<td>{$and_rarest}</td>
							<td align="right">{$and_rarest_percentage} %</td>
						</tr>
						<tr>
							<td>visited OR hosted</td>
							<td align="right">{$or_flags}</td>
							<td align="right">{$or_flags_percentage} %</td>
							<td align="right">{$or_coolness|number_format:2:".":" "}</td>
							<td align="right">{$or_coolness_percentage} %</td>
							<td>{$or_rarest}</td>
							<td align="right">{$or_rarest_percentage} %</td>
						</tr>
						<tr>
							<td>visited PLUS hosted</td>
							<td align="right">{$plus_flags}</td>
							<td align="right">{$plus_flags_percentage} %</td>
							<td align="right">{$plus_coolness|number_format:2:".":" "}</td>
							<td align="right">{$plus_coolness_percentage} %</td>
							<td>{$plus_rarest}</td>
							<td align="right">{$plus_rarest_percentage} %</td>
						</tr>
				</table>
				<div align="left">{$explanation}</div>
			</div>
		</div>
	</div>
</div>
{/if}
	
</div>